//--------------------ip----------------------------------
//window.getIps = "http://carnt.carnettong.com:8088"
//window.getIps = "http://4scafe.carnettong.com"
//window.getIps = "http://192.168.0.123" //振豪
window.getIps = 'http://192.168.0.180:8088' //双胜
//window.getIps = "http://192.168.0.144:8080"
import Vue from 'vue'
import 'normalize.css/normalize.css' // css样式重置
import 'element-ui/lib/theme-chalk/index.css'
import '@/styles/index.scss' // 全局css
import Element from 'element-ui'
import App from './App'
import router from './router'
import store from './store'
// import i18n from './lang' // 国际化
import './icons' // icon
import './permission' // 身份验证以及跳转进度条控制
import './mock' // 模拟数据（用于demo展示）
import axios from 'axios'
import qs from 'qs'
Vue.prototype.$axiosCK = axios; //全局axios配置
Vue.prototype.$qsCK = qs; //全局qs配置
import * as filters from './filters' // global filters
// Vue.use(Element, {
//   size: 'medium', // set element-ui default size
//   i18n: (key, value) => i18n.t(key, value)
// })
Vue.use(Element)
// 注册全局过滤器
Object.keys(filters).forEach(key => {
	Vue.filter(key, filters[key])
})
Vue.config.productionTip = false
Vue.filter("filterTimes", function(val) {
	let y = new Date(val).getFullYear();
	let m = new Date(val).getMonth() + 1 >= 10 ? new Date(val).getMonth() + 1 : '0' + (new Date(val).getMonth() + 1);
	let d = new Date(val).getDate() >= 10 ? new Date(val).getDate() : '0' + new Date(val).getDate();
	return y + "-" + m + "-" + d;
})
Vue.filter("filterTimess", function(val) {
	let y = new Date(val).getFullYear();
	let m = new Date(val).getMonth() + 1 >= 10 ? new Date(val).getMonth() + 1 : '0' + (new Date(val).getMonth() + 1);
	let d = new Date(val).getDate() >= 10 ? new Date(val).getDate() : '0' + new Date(val).getDate();
	let h = new Date(val).getHours() >= 10 ? new Date(val).getHours() : '0' + new Date(val).getHours();
	let ms = new Date(val).getMinutes() >= 10 ? new Date(val).getMinutes() : '0' + new Date(val).getMinutes();
	let s = new Date(val).getSeconds() >= 10 ? new Date(val).getSeconds() : '0' + new Date(val).getSeconds();
	return y + "-" + m + "-" + d + " " + h + ":" + ms + ":" + s;
})
Vue.filter("filterTimesss", function(val) {
	let y = new Date(val).getFullYear();
	let m = new Date(val).getMonth() + 1 >= 10 ? new Date(val).getMonth() + 1 : '0' + (new Date(val).getMonth() + 1);
	let d = new Date(val).getDate() >= 10 ? new Date(val).getDate() : '0' + new Date(val).getDate();
	let h = new Date(val).getHours() >= 10 ? new Date(val).getHours() : '0' + new Date(val).getHours();
	let ms = new Date(val).getMinutes() >= 10 ? new Date(val).getMinutes() : '0' + new Date(val).getMinutes();
	return y + "-" + m + "-" + d + " " + h + ":" + ms;
})

function axiosPost(url, params) {
	return new Promise((resolve, reject) => {
		axios({
			url: window.getIps + url,
			method: 'post',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
			},
			data: qs.stringify(params)
		}).then(res => {
			resolve(res.data);
		}).catch((error) => {
			reject(error)
		})
	})
}

function axiosGet(url, params) {
	return new Promise((resolve, reject) => {
		axios({
			url: window.getIps + url,
			method: 'get',
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
			},
			data: qs.stringify(params)
		}).then(res => {
			resolve(res.data);
		}).catch((error) => {
			reject(error)
		})
	})
}
Vue.prototype.$axiosPost = axiosPost; //全局axiosPost配置----------交互就用这个足够
Vue.prototype.$axiosGet = axiosGet; //全局axiosGet配置
new Vue({
	el: '#app',
	router,
	store,
	// i18n,
	template: '<App/>',
	components: {
		App
	}
})